﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Qu.SeniorProject.Model;

namespace Qu.SeniorProject.WebUI.Controllers
{
    public class SupervisorAjaxDropdownController : Controller
    {
        public ActionResult GetItems(int? key, int? parent)
        {
            var list = new List<SelectListItem> { new SelectListItem { Text = "not selected", Value = "" } };
            list.AddRange(
                UserRepository.GetAll().Select(o => new SelectListItem
                {
                    Text = o.Name,
                    Value = o.FacultyId.ToString(),
                    Selected = o.FacultyId == key
                }));
            return Json(list);
        }
    }
}
